const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");

module.exports = {
  entry: "./src/index.js",
  output: {
    filename: "[name].js",
    path: path.resolve(__dirname, "dist"),
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: "./index.html",
    }),
    new ModuleFederationPlugin({
      filename: "mainApp.js",
      name: "AppMain",
      remotes: {
        sub: "AppSub@http://localhost:3000/subAppEntry", // sub别名
      },
    }),
  ],
  devServer: {
    port: 3001,
    hot: true,
  },
};
